package testcase.ut;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class UFiles {


	public static byte[] readFile(String filePath) {
		byte[] by = null;
		FileInputStream fis = null;
		try {
			File fp = new File(filePath);
			fis = new FileInputStream(fp);

			by = new byte[(int) fp.length()];
			fis.read(by);
		} catch (Exception e) {
			by = null;
		} finally {
			if (fis != null) {
				try {
					fis.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return by;
	}
	
    public static void saveFile(String filePath, byte[] data) {
    	FileOutputStream fos = null;
    	try {
	        File file = new File(filePath);
	        fos = new FileOutputStream(file);
	        fos.write(data);
	        fos.flush();
    	} catch (Exception e) {
    		e.printStackTrace();
    	} finally {
    		if (fos != null) {
    			try {
					fos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
    		}
    	}
    }
		
}
